DEBUG = 0

TARGETS = ['ciadditioncompositing',
		'cibloom',
		'ciboxblur',
		'cibumpdistortion',
		'cibumpdistortionlinear',
		'cicheckerboardgenerator',
		'cicirclesplashdistortion',
		'cicircularscreen',
		'cicircularwrap',
		'cicmykhalftone',
		'cicolorcontrols',
		'cicolorinvert',
		'cicolormonochrome',
		'cicolorposterize',
		'cicomiceffect',
		'cicrop',
		'cicrystallize',
		'cidiscblur',
		'cidisplacementdistortion',
		'cidotscreen',
		'ciedges',
		'ciedgework',
		'cieightfoldreflectedtile',
		'ciexposureadjust',
		'cifalsecolor',
		'cifourfoldrotatedtile',
		'cifourfoldtranslatedtile',
		'cigammaadjust',
		'cigaussianblur',
		'cigaussiangradient',
		'ciglidereflectedtile',
		'cigloom',
		'cihatchedscreen',
		'ciheightfieldfrommask',
		'cihexagonalpixellate',
		'ciholedistortion',
		'cihueadjust',
		'cikaleidoscope',
		'cilanczosscaletransform',
		'cilenticularhalogenerator',
		'cilineargradient',
		'cilineoverlay',
		'cilinescreen',
		'cimasktoalpha',
		'cimaximumcomponent',
		'cimedianfilter',
		'ciminimumcomponent',
		'cimotionblur',
		'cinoisereduction',
		'cioptile',
		'ciparallelogramtile',
		'ciperspectivetile',
		'ciperspectivetransform',
		'cipinchdistortion',
		'cipixellate',
		'cipointillize',
		'ciradialgradient',
		'cirandomgenerator',
		'cirowaverage',
		'cisepiatone',
		'cisharpenluminance',
		'cisixfoldreflectedtile',
		'cisixfoldrotatedtile',
		'cispotcolor',
		'cispotlight',
		'cistarshinegenerator',
		'cistripesgenerator',
		'cisunbeamsgenerator',
		'citoruslensdistortion',
		'citriangletile',
		'citwelvefoldreflectedtile',
		'citwirldistortion',
		'ciunsharpmask',
		'civortexdistortion',
		'ciwhitepointadjust',
		'cizoomblur']

DEFINES = [
		'-DFILTER_NAME=\'"CIAdditionCompositing"\' -DFILTER_ID=\'"CIAC"\' ',
		'-DFILTER_NAME=\'"CIBloom"\' -DFILTER_ID=\'"CIBL"\' ',
		'-DFILTER_NAME=\'"CIBoxBlur"\' -DFILTER_ID=\'"CIBB"\' ',
		'-DFILTER_NAME=\'"CIBumpDistortion"\' -DFILTER_ID=\'"CIBD"\' ',
		'-DFILTER_NAME=\'"CIBumpDistortionLinear"\' -DFILTER_ID=\'"CIBL"\' ',
		'-DFILTER_NAME=\'"CICheckerboardGenerator"\' -DFILTER_ID=\'"CICG"\' ',
		'-DFILTER_NAME=\'"CICircleSplashDistortion"\' -DFILTER_ID=\'"CISD"\' ',
		'-DFILTER_NAME=\'"CICircularScreen"\' -DFILTER_ID=\'"CICS"\' ',
		'-DFILTER_NAME=\'"CICircularWrap"\' -DFILTER_ID=\'"CICW"\' ',
		'-DFILTER_NAME=\'"CICMYKHalftone"\' -DFILTER_ID=\'"CIHT"\' ',
		'-DFILTER_NAME=\'"CIColorControls"\' -DFILTER_ID=\'"CICC"\' ',
		'-DFILTER_NAME=\'"CIColorInvert"\' -DFILTER_ID=\'"CICI"\' ',
		'-DFILTER_NAME=\'"CIColorMonochrome"\' -DFILTER_ID=\'"CICM"\' ',
		'-DFILTER_NAME=\'"CIColorPosterize"\' -DFILTER_ID=\'"CICP"\' ',
		'-DFILTER_NAME=\'"CIComicEffect"\' -DFILTER_ID=\'"CICE"\' ',
		'-DFILTER_NAME=\'"CICrop"\' -DFILTER_ID=\'"CICR"\' ',
		'-DFILTER_NAME=\'"CICrystallize"\' -DFILTER_ID=\'"CICY"\' ',
		'-DFILTER_NAME=\'"CIDiscBlur"\' -DFILTER_ID=\'"CIDB"\' ',
		'-DFILTER_NAME=\'"CIDisplacementDistortion"\' -DFILTER_ID=\'"CIDD"\' ',
		'-DFILTER_NAME=\'"CIDotScreen"\' -DFILTER_ID=\'"CIDS"\' ',
		'-DFILTER_NAME=\'"CIEdges"\' -DFILTER_ID=\'"CIED"\' ',
		'-DFILTER_NAME=\'"CIEdgeWork"\' -DFILTER_ID=\'"CIEW"\' ',
		'-DFILTER_NAME=\'"CIEightfoldReflectedTile"\' -DFILTER_ID=\'"CIER"\' ',
		'-DFILTER_NAME=\'"CIExposureAdjust"\' -DFILTER_ID=\'"CIEA"\' ',
		'-DFILTER_NAME=\'"CIFalseColor"\' -DFILTER_ID=\'"CIFC"\' ',
		'-DFILTER_NAME=\'"CIFourfoldRotatedTile"\' -DFILTER_ID=\'"CIFR"\' ',
		'-DFILTER_NAME=\'"CIFourfoldTranslatedTile"\' -DFILTER_ID=\'"CIFT"\' ',
		'-DFILTER_NAME=\'"CIGammaAdjust"\' -DFILTER_ID=\'"CIGA"\' ',
		'-DFILTER_NAME=\'"CIGaussianBlur"\' -DFILTER_ID=\'"CIGB"\' ',
		'-DFILTER_NAME=\'"CIGaussianGradient"\' -DFILTER_ID=\'"CIGG"\' ',
		'-DFILTER_NAME=\'"CIGlideReflectedTile"\' -DFILTER_ID=\'"CIRT"\' ',
		'-DFILTER_NAME=\'"CIGloom"\' -DFILTER_ID=\'"CIGL"\' ',
		'-DFILTER_NAME=\'"CIHatchedScreen"\' -DFILTER_ID=\'"CIHS"\' ',
		'-DFILTER_NAME=\'"CIHeightFieldFromMask"\' -DFILTER_ID=\'"CIHF"\' ',
		'-DFILTER_NAME=\'"CIHexagonalPixellate"\' -DFILTER_ID=\'"CIHP"\' ',
		'-DFILTER_NAME=\'"CIHoleDistortion"\' -DFILTER_ID=\'"CIHD"\' ',
		'-DFILTER_NAME=\'"CIHueAdjust"\' -DFILTER_ID=\'"CIHA"\' ',
		'-DFILTER_NAME=\'"CIKaleidoscope"\' -DFILTER_ID=\'"CIKA"\' ',
		'-DFILTER_NAME=\'"CILanczosScaleTransform"\' -DFILTER_ID=\'"CILT"\' ',
		'-DFILTER_NAME=\'"CILenticularHaloGenerator"\' -DFILTER_ID=\'"CILH"\' ',
		'-DFILTER_NAME=\'"CILinearGradient"\' -DFILTER_ID=\'"CILG"\' ',
		'-DFILTER_NAME=\'"CILineOverlay"\' -DFILTER_ID=\'"CILO"\' ',
		'-DFILTER_NAME=\'"CILineScreen"\' -DFILTER_ID=\'"CILS"\' ',
		'-DFILTER_NAME=\'"CIMaskToAlpha"\' -DFILTER_ID=\'"CIMA"\' ',
		'-DFILTER_NAME=\'"CIMaximumComponent"\' -DFILTER_ID=\'"CIMC"\' ',
		'-DFILTER_NAME=\'"CIMedianFilter"\' -DFILTER_ID=\'"CIMF"\' ',
		'-DFILTER_NAME=\'"CIMinimumComponent"\' -DFILTER_ID=\'"CIMI"\' ',
		'-DFILTER_NAME=\'"CIMotionBlur"\' -DFILTER_ID=\'"CIMB"\' ',
		'-DFILTER_NAME=\'"CINoiseReduction"\' -DFILTER_ID=\'"CINR"\' ',
		'-DFILTER_NAME=\'"CIOpTile"\' -DFILTER_ID=\'"CIOT"\' ',
		'-DFILTER_NAME=\'"CIParallelogramTile"\' -DFILTER_ID=\'"CIPT"\' ',
		'-DFILTER_NAME=\'"CIPerspectiveTile"\' -DFILTER_ID=\'"CIPE"\' ',
		'-DFILTER_NAME=\'"CIPerspectiveTransform"\' -DFILTER_ID=\'"CIPR"\' ',
		'-DFILTER_NAME=\'"CIPinchDistortion"\' -DFILTER_ID=\'"CIPD"\' ',
		'-DFILTER_NAME=\'"CIPixellate"\' -DFILTER_ID=\'"CIPX"\' ',
		'-DFILTER_NAME=\'"CIPointillize"\' -DFILTER_ID=\'"CIPO"\' ',
		'-DFILTER_NAME=\'"CIRadialGradient"\' -DFILTER_ID=\'"CIRG"\' ',
		'-DFILTER_NAME=\'"CIRandomGenerator"\' -DFILTER_ID=\'"CIRD"\' ',
		'-DFILTER_NAME=\'"CIRowAverage"\' -DFILTER_ID=\'"CIRA"\' ',
		'-DFILTER_NAME=\'"CISepiaTone"\' -DFILTER_ID=\'"CIST"\' ',
		'-DFILTER_NAME=\'"CISharpenLuminance"\' -DFILTER_ID=\'"CISL"\' ',
		'-DFILTER_NAME=\'"CISixfoldReflectedTile"\' -DFILTER_ID=\'"CISR"\' ',
		'-DFILTER_NAME=\'"CISixfoldRotatedTile"\' -DFILTER_ID=\'"CISD"\' ',
		'-DFILTER_NAME=\'"CISpotColor"\' -DFILTER_ID=\'"CISC"\' ',
		'-DFILTER_NAME=\'"CISpotLight"\' -DFILTER_ID=\'"CISP"\' ',
		'-DFILTER_NAME=\'"CIStarShineGenerator"\' -DFILTER_ID=\'"CISH"\' ',
		'-DFILTER_NAME=\'"CIStripesGenerator"\' -DFILTER_ID=\'"CISG"\' ',
		'-DFILTER_NAME=\'"CISunbeamsGenerator"\' -DFILTER_ID=\'"CISB"\' ',
		'-DFILTER_NAME=\'"CITorusLensDistortion"\' -DFILTER_ID=\'"CITL"\' ',
		'-DFILTER_NAME=\'"CITriangleTile"\' -DFILTER_ID=\'"CITT"\' ',
		'-DFILTER_NAME=\'"CITwelvefoldReflectedTile"\' -DFILTER_ID=\'"CITW"\' ',
		'-DFILTER_NAME=\'"CITwirlDistortion"\' -DFILTER_ID=\'"CITD"\' ',
		'-DFILTER_NAME=\'"CIUnsharpMask"\' -DFILTER_ID=\'"CIUM"\' ',
		'-DFILTER_NAME=\'"CIVortexDistortion"\' -DFILTER_ID=\'"CIVD"\' ',
		'-DFILTER_NAME=\'"CIWhitePointAdjust"\' -DFILTER_ID=\'"CIWP"\' ',
		'-DFILTER_NAME=\'"CIZoomBlur"\' -DFILTER_ID=\'"CIZB"\' ']

AddOption('--bundle', action='store_true', help='Build OSX bundle instead of .dylib')

# check the availability of libraries
env = Environment()

LIBLIST = [['m', 'math.h'],
		   ['GLEW', 'GL/glew.h']]

LIBS = []

LIBPATH = ['-L/opt/local/lib']
INCPATH = ['-I/opt/local/include']

env.Append(CPPPATH = INCPATH)
env.Append(LIBPATH = LIBPATH)

if not GetOption('clean'):
	conf = Configure(env)
	for (lib, headers) in LIBLIST:
		if not conf.CheckLibWithHeader(lib, headers, 'c++', autoadd=0):
			print "error: '%s' must be installed!" % lib
			Exit(1)
		LIBS += [lib]
	env = conf.Finish()

for i in range(len(TARGETS)):
	TARGET = TARGETS[i]
	ECCFLAGS = INCPATH[0] + ' ' + DEFINES[i]
	Export(['DEBUG', 'TARGET', 'ECCFLAGS', 'LIBS', 'LIBPATH'])
	SConscript('SConscript', variant_dir = TARGET, duplicate = 0)

